<style>
    li .left-list-op { display: none; }
    li:hover .left-list-op { display: block; }
    .shenfen_check { border: 1px solid #d9d9d9; }
    .shenfen_check li { cursor: default; position: relative; height: 25px; float: left; margin: 8px 10px; background-color: #fff; border: 1px solid #d9d9d9; padding: 0px 20px; line-height: 25px; }
    .shenfen_check li .ui-dialog-close { display: none; position: absolute; top: 0; right: 0; height: 25px; font-size: 21px; font-weight: bold; line-height: 1; color: #000; text-shadow: 0 1px 0 #FFF; opacity: .2; filter: alpha(opacity=20); cursor: pointer; background: transparent; border: 0; -webkit-appearance: none; }
    .shenfen_check li:hover .ui-dialog-close { display: block; }
</style>
<form name="commission_rules_form" ng-controller="CommissionRulesController" novalidate>
    <table width="100%" class="mt10">
        <tbody>
        <tr>
            <td align="right" class="form-cell w88 pt16" valign="top"><em class="c-red">*&nbsp;</em>带看佣金：</td>
            <td class="pt12">
                <input type="number" class="input-text mr5 w120" name="ShowHouseBonus"
                       ng-model="data.jy.ShowHouseBonus" required integer min="0">元

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.ShowHouseBonus.$touched) && commission_rules_form.ShowHouseBonus.$error.required"
                      class="error ng-hide c-red lh30">带看佣金不能为空</span>

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.ShowHouseBonus.$touched)
                      && (commission_rules_form.ShowHouseBonus.$error.number || commission_rules_form.ShowHouseBonus.$error.min)"
                      class="error ng-hide c-red lh30">带看佣金需为大于0的整数</span>
            </td>
        </tr>
        <tr>
            <td align="right" class="form-cell w88 pt16" valign="top"><em class="c-red">*&nbsp;</em>认筹佣金：</td>
            <td class="pt12">
                <input type="number" name="IdentificationChipsBonus" class="input-text mr5 w120"
                       ng-model="data.jy.IdentificationChipsBonus" required integer min="0">元

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.IdentificationChipsBonus.$touched) && commission_rules_form.IdentificationChipsBonus.$error.required"
                      class="error ng-hide c-red lh30">认筹佣金不能为空</span>

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.IdentificationChipsBonus.$touched)
                      && (commission_rules_form.IdentificationChipsBonus.$error.number || commission_rules_form.IdentificationChipsBonus.$error.min)"
                      class="error ng-hide c-red lh30">带看佣金需为大于0的整数</span>
            </td>
        </tr>
        <tr>
            <td align="right" class="form-cell w88 pt16" valign="top">成交佣金：</td>
            <td class="pt12"></td>
        </tr>
        </tbody>
    </table>

    <div class="border mt5 ml25 clearfix">
        <div class="top_list">
            <div class="row clearfix mt10 pb10">
                <div class="col-md-2"><em class="c-red ml10">*&nbsp;</em>发放条件：</div>
                <div class="col-md-10">
                    <div>
                        <div class="radio-list">
                            <div class="radio">
                                <input type="radio" value="7" id="radio_buy"
                                       ng-model="data.fftj.paravalue" value="7">
                                <label for="radio_buy">认购后发放</label>
                            </div>
                            <div class="radio">
                                <input type="radio" value="8" id="radio_contract"
                                       ng-model="data.fftj.paravalue" value="8">
                                <label for="radio_contract">签约后发放</label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="clearfix relative">
            <div class="left-list h652 ">
                <div class="clearfix" style="padding:10px;">
                    <a href="javascript:;" class="fl btn btn-yellow permission p-500302-05-inline-block"
                       id="btn_add_type"
                       ui-dialog="新增规则"
                       ui-dialog-show="showEditRule($data,$dialog,$dialogScope)"
                       ui-dialog-ok="addRule($data,$dialog,$dialogScope)"
                       ui-dialog-cache="false"
                       ui-dialog-url="inc/dialog/commission_rule_edit.html"><i class="btn-icon-add"></i>新增规则</a></div>
                <div id="type_tree">
                    <div class="pl10" ng-if="loading">加载中。。。</div>
                    <div class="pl10" ng-if="!loading && (!data.rule_help || data.rule_help.length==0)">暂无规则
                    </div>

                    <ul ng-if="!loading && (data.rule_help && data.rule_help.length>0)">
                        <li class="clearfix" ng-repeat="item in data.rule_help"
                            ng-class="{selected:item.help_id === curRule.help_id}"
                            ng-click="setRuleSelected(item)">
                            <span class="left-list-text">{{item.rule_name}}</span>
                        <span class="fr left-list-op">
                            <a href="javascript:;"
                               ui-dialog="编辑规则"
                               ui-dialog-data="item"
                               ui-dialog-ok="editRuleName($data,$dialog,$dialogScope)"
                               ui-dialog-cache="false"
                               ui-dialog-url="inc/dialog/commission_rule_name_edit.html">
                                <i class="icon-op icon-op-edit"></i>
                            </a>
                            <a href="javascript:;" ng-click="deleteRule(item,$event)">
                                <i class="icon-op icon-op-del"></i>
                            </a>
                        </span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="left-list-bd" style="left:269px"></div>

            <div class="left-list-con" style="width:677px">
                <div ng-if="!curRuleDetail" class="text-center mt50">请选择规则</div>

                <div ng-if="curRuleDetail">
                    <div class="grid-header">
                        <span class="fl f14 lh30 text-indent">规则适用身份：</span>
                        <a href="javascript:;" class="fr btn btn-yellow permission p-500302-05-inline-block"
                           ui-dialog="添加身份"
                           ui-dialog-show="showAddIdentity($data,$dialog,$dialogScope)"
                           ui-dialog-ok="addIdentities($data,$dialog,$dialogScope)"
                           ui-dialog-cache="false"
                           ui-dialog-url="inc/dialog/commission_rule_add_identity.html">添加身份</a>
                    </div>
                    <ul class="shenfen_check bgcf7 c-gray clearfix">
                        <li ng-repeat="item in curRuleDetail.identityInfos">
                            {{item.name}}
                            <button i="close" class="ui-dialog-close" title="删除" ng-click="deleteIdentity(item)">×
                            </button>
                        </li>
                    </ul>
                    <div class="grid-header mt10">
                        <span class="fl f14 lh30 text-indent">类型：</span>
                        <a href="javascript:;" class="fr btn btn-yellow  permission p-500302-05-inline-block"
                           ng-click="addRuleType()">添加类型</a>
                    </div>
                    <div class="border text-center p10"
                         ng-if="!curRuleDetail.rule.content || curRuleDetail.rule.content.length==0">暂无类型
                    </div>
                    <div class="border" ng-repeat="ruleItem in curRuleDetail.rule.content" ng-class="{mt5:$index>0}"
                         ng-if="curRuleDetail.rule.content && curRuleDetail.rule.content.length>0">
                        <div class="border-bottom p10 bgcf7 clearfix">
                            <div class="fl mt5">类型{{$index+1}}：</div>

                            <div class="fl w200" ui-combobox data="productTypeList" text-field="Text"
                                 value-field="Text"
                                 ng-model="ruleItem.ProductType" required></div>

                            <div class="fl w200 ml10" ui-combobox data="calculateTypes" text-field="name"
                                 value-field="value"
                                 ng-model="ruleItem.CalcRule" ng-change="changeCalculateType(ruleItem)"></div>

                            <a href="javascript:void(0)" title="删除" class="fr mt5 mr15"
                               ng-click="deleteRuleType(ruleItem)">
                                <i class="icon-op icon-op-del">&nbsp;</i>
                            </a>
                        </div>
                        <div class="p10">

                            <div ng-if="ruleItem.CalcRule == 1">
                                <!--{"Percentage" : 200, "GuaranteesAmount" : 0 ,"CapAmount" : 200}-->
                                成交佣金＝成交金额＊<input type="number" class="input-text mr10" style="width:60px"
                                                 ng-model="ruleItem.ruleOne.Percentage" required min="0.01" step="0.01"
                                                 name="percentage_{{$index}}">‰，
                                保底金额 <input type="number" class="input-text mr10" style="width:80px"
                                            ng-model="ruleItem.ruleOne.GuaranteesAmount" required integer min="0"
                                            name="guaranteesAmount_{{$index}}">元，封顶金额
                                <input type="number" class="input-text mr10" style="width:80px"
                                       ng-model="ruleItem.ruleOne.CapAmount" required integer min="0"
                                       name="capAmount_{{$index}}">元

                                <div role="alert"
                                     ng-show="(commission_rules_form.$submitted || commission_rules_form['percentage_'+$index].$touched) &&
                                     (commission_rules_form['percentage_'+$index].$error.number || commission_rules_form['percentage_'+$index].$error.required || commission_rules_form['percentage_'+$index].$error.min)"
                                     class="error ng-hide c-red lh30">成交比例需大于0.01数字
                                </div>
                                <div role="alert"
                                     ng-show="(commission_rules_form.$submitted || commission_rules_form['guaranteesAmount_'+$index].$touched) &&
                                     (commission_rules_form['guaranteesAmount_'+$index].$error.number || commission_rules_form['guaranteesAmount_'+$index].$error.required || commission_rules_form['guaranteesAmount_'+$index].$error.min)"
                                     class="error ng-hide c-red lh30">保底金额需为大于0数字
                                </div>
                                <div role="alert"
                                     ng-show="(commission_rules_form.$submitted || commission_rules_form['capAmount_'+$index].$touched) &&
                                     (commission_rules_form['capAmount_'+$index].$error.number || commission_rules_form['capAmount_'+$index].$error.requied|| commission_rules_form['capAmount_'+$index].$error.min)"
                                     class="error ng-hide c-red lh30">封顶金额需为大于0数字
                                </div>
                            </div>

                            <div ng-if="ruleItem.CalcRule == 2">
                                固定成交金额：<input type="number" class="input-text mr10" ng-model="ruleItem.ruleOne.Amount"
                                              integer required min="1" name="amount_{{$index}}"
                                              style="width:60px">元
                                <span role="alert"
                                      ng-show="(commission_rules_form.$submitted || commission_rules_form['amount_'+$index].$touched)
                                      && (commission_rules_form['amount_'+$index].$error.number || commission_rules_form['amount_'+$index].$error.required || commission_rules_form['amount_'+$index].$error.min)"
                                      class="error ng-hide c-red lh30">固定成交金额需为大于0数字
                                </span>
                            </div>

                            <!--[
                                {"LowerLimit" : 0, "HigherLimit" : 20, "Amout" : 10},
                                {"LowerLimit" : 20, "HigherLimit" : 30, "Amout" : 30},
                                {"LowerLimit" : 30, "HigherLimit" : 40, "Amout" : 40}
                            ]-->
                            <div ng-if="ruleItem.CalcRule == 3">
                                <div class="sheet">
                                    <table width="100%">
                                        <thead>
                                        <tr>
                                            <th style="height:35px;width:38px">序号</th>
                                            <th>条件</th>
                                            <th style="width:130px">佣金额</th>
                                            <th style="width:50px">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="ruleOneItem in ruleItem.ruleOne">
                                            <td style="height:40px;">{{$index+1}}</td>
                                            <td>
                                                大于等于<input type="number" class="input-text mr10" value="0"
                                                           style="width:60px"
                                                           ng-model="ruleOneItem.LowerLimit" required
                                                           min="0" step="0.0001" name="LowerLimit{{$index}}">万元，
                                                小于<input type="number" class="input-text mr10" value=""
                                                         style="width:60px"
                                                         ng-model="ruleOneItem.HigherLimit" required
                                                         name="HigherLimit{{$index}}"
                                                         min="0" step="0.0001">万元

                                                <div role="alert"
                                                     ng-show="(commission_rules_form.$submitted || commission_rules_form['LowerLimit'+$index].$touched)
                                                     && (commission_rules_form['LowerLimit'+$index].$error.number ||
                                                      commission_rules_form['LowerLimit'+$index].$error.min ||
                                                      commission_rules_form['LowerLimit'+$index].$error.required)"
                                                     class="error ng-hide c-red lh30">区间下限需大于0数字
                                                </div>
                                                <div role="alert"
                                                     ng-show="(commission_rules_form.$submitted || commission_rules_form['HigherLimit'+$index].$touched)
                                                     && (commission_rules_form['HigherLimit'+$index].$error.number ||
                                                      commission_rules_form['HigherLimit'+$index].$error.min ||
                                                      commission_rules_form['HigherLimit'+$index].$error.required)"
                                                     class="error ng-hide c-red lh30">区间上限需大于0数字
                                                </div>
                                            </td>
                                            <td>
                                                <input type="number" class="input-text mr10" value="0"
                                                       style="width:60px"
                                                       ng-model="ruleOneItem.Amout" required min="0"
                                                       name="itemAmount_{{$index}}">元
                                                <div role="alert"
                                                     ng-show="(commission_rules_form.$submitted || commission_rules_form['itemAmount_'+$index].$touched)
                                                     && (commission_rules_form['itemAmount_'+$index].$error.number ||
                                                      commission_rules_form['itemAmount_'+$index].$error.min ||
                                                      commission_rules_form['itemAmount_'+$index].$error.required)"
                                                     class="error ng-hide c-red lh30">佣金额需为大于0数字
                                                </div>
                                            </td>
                                            <td>
                                                <a href="javascript:void(0)" title="删除" class="mt5 mr15"
                                                   ng-click="deleteRangeRule(ruleOneItem,ruleItem.ruleOne)">
                                                    <i class="icon-op icon-op-del">&nbsp;</i>
                                                </a>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="mt5 clearfix">
                                    <a href="javascript:;" class="fl c-orange f14 block"
                                       ng-click="addRangeRule(ruleItem.ruleOne)">
                                        <i class="ui-icon icon-add1"></i>添加条件
                                    </a>
                                    <span class="c-gray fl">（未覆盖的成交额，按未定义算法处理，佣金计算值为0）</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="grid-header mt10">
                        <span class="fl f14 lh30 text-indent">佣金笔数：</span>
                    </div>
                    <div class="border">
                        <div class="border-bottom p10 bgcf7 clearfix">
                            <span class="form-cell fl" valign="top">设置每笔佣金发放比例：</span>
                        </div>
                        <div class="sheet p10">
                            <table width="100%">
                                <thead>
                                <tr>
                                    <th height="34">笔数</th>
                                    <th>条件</th>
                                    <th>计算方式(成交佣金百分比)</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in curRuleDetail.ruleTwo">
                                    <td width="60" height="34">{{item.Num}}</td>
                                    <td width="300">
                                        <input type="text" class="input-text mr10" ng-model="item.Conditions"
                                               style="width:100%" required name="Conditions{{$index}}">
                                    </td>
                                    <td align="left">
                                        <input type="number" class="input-text mr10" ng-model="item.Proportion"
                                               required
                                               style="width:80px" name="Proportion{{$index}}">%
                                    </td>
                                    <td>
                                        <a href="javascript:void(0)" title="删除" class="mt5 left-list-op"
                                           ng-click="deleteCommission(item,curRuleDetail.ruleTwo)"
                                           ng-if="curRuleDetail.ruleTwo.length>1">
                                            <i class="icon-op icon-op-del">&nbsp;</i>
                                        </a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <div class="mt5 clearfix" ng-if="!curRuleDetail.ruleTwo || curRuleDetail.ruleTwo.length<3">
                                <a href="javascript:;" class="fl c-orange f14 block"
                                   ng-click="addCommission(curRuleDetail.ruleTwo)">
                                    <i class="ui-icon icon-add1"></i>添加条件
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <table width="100%" class="mt10">
        <tbody>
        <tr>
            <td align="right" class="form-cell w175 pt16" valign="top"><em class="c-red">*&nbsp;</em>邀请经纪人成交奖励设置：</td>
            <td class="pt12">
                <input type="number" name="InviteBrokerDealBonus" class="input-text mr5 w120"
                       ng-model="data.jy.InviteBrokerDealBonus" required min="0">元

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.InviteBrokerDealBonus.$touched) && commission_rules_form.InviteBrokerDealBonus.$error.required"
                      class="error ng-hide c-red lh30">不能为空</span>

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.InviteBrokerDealBonus.$touched) && commission_rules_form.InviteBrokerDealBonus.$error.number"
                      class="error ng-hide c-red lh30">奖励设置需为大于0的数值</span>
            </td>
        </tr>
        <tr>
            <td align="right" class="form-cell w175 pt16" valign="top"><em class="c-red">*&nbsp;</em>申请结佣提示语：</td>
            <td class="pt12">
                <input type="text" name="jyts" class="input-text mr5 w400"
                       ng-model="data.jyts.value" required>

                <span role="alert"
                      ng-show="(commission_rules_form.$submitted || commission_rules_form.jyts.$touched) && commission_rules_form.jyts.$error.required"
                      class="error ng-hide c-red lh30">不能为空</span>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="pt12">
                <button type="submit" href="javascript:;" class="btn fr permission p-500302-06-inline-block"
                        id="save_rule" ng-click="saveRule(commission_rules_form)">保存设置
                </button>
            </td>
        </tr>
        </tbody>
    </table>
</form>